<template>
    <div class="container">
        <header id="header" class="mui-bar mui-bar-nav">
            <router-link class="mui-icon mui-icon-search mui-icon mui-icon-right-nav mui-pull-right" to="/search"></router-link>
            <h1 class="mui-title">购物</h1>
        </header>
        <router-view>

        </router-view>
        <nav class="mui-bar mui-bar-tab">
            <router-link class="mui-tab-item" to="/home">
                <span class="mui-icon mui-icon-home"></span>
                <span class="mui-tab-label">首页</span>
            </router-link>
            <router-link class="mui-tab-item" to="/cate">
                <span class="mui-icon  mui-icon-bars"></span>
                <span class="mui-tab-label">分类</span>
            </router-link>
            <a class="mui-tab-item" @click.prevent="move2Cart">
                <span class="mui-icon  mui-icon-extra mui-icon-extra-cart"><span class="mui-badge">0</span></span>
                <span class="mui-tab-label">购物车</span>
            </a>
            <a class="mui-tab-item" @click.prevent="move2User">
                <span class="mui-icon mui-icon-person"></span>
                <span class="mui-tab-label">会员中心</span>
            </a>
        </nav>
    </div>
</template>
<style scoped lang="css">
    *{
        touch-action: none!important;
    }

    .container{
        padding-top: 40px;
        padding-bottom: 50px;
    }
    .tabber-active{
        color: #007aff!important;
    }
</style>
<script>
    export default {
        methods:{
            move2Cart(){
                var user =JSON.parse(localStorage.getItem('user'));
                if(user === '[]' || !localStorage.getItem('user')){
                    this.$router.push('/login');
                }else{
                    //var id = JSON.parse(localStorage.getItem('id'));
                   // console.log(id);
                    this.$router.push('/cart');
                }
            },
            move2User(){
                var user =JSON.parse(localStorage.getItem('user'));
                if(user === '[]' || !localStorage.getItem('user')){
                    this.$router.push('/login');
                }else{
                    var id = JSON.parse(localStorage.getItem('id'));
                    console.log(id);
                    this.$router.push('/user');
                }
            }
        }

    }
</script>